﻿
using System.ComponentModel;

namespace Game.Command
{
    /// <summary>
    ///  A Command is an action that the player initiates.
    /// </summary>
    public abstract class GameCommand
        : Actions.GameAction, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        static int _CommandCount;
        readonly int _CommandIndex;
        bool _IsEnabled;

        protected GameCommand() 
        {
            _CommandIndex = ++_CommandCount;
        }

        public abstract string Name
        {
            get;
        }

        public virtual bool IsEnabled
        {
            get { return _IsEnabled; } 
            protected set
            {
                _IsEnabled = value;
                FirePropertyChanged();
            }
        }

        void FirePropertyChanged()
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("IsEnbled"));
            }
        }

        public override string ToString()
        {
            return "Command{" + _CommandIndex + "}";
        }

    }
}